import example.Course;
import example.MyBeanClass;
import example.Student;
import example.Teacher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//        MyBeanClass myBean = (MyBeanClass) context.getBean("myBean");
//        // 现在可以使用myBean对象了
//
//        // retrieve configured instance 1
//        MyBeanClass myBean = context.getBean("myBean", MyBeanClass.class);
//
//        // retrieve configured instance 2
//        MyBeanClass myBean = (MyBeanClass) context.getBean("myBean");
//
//        // retrieve configured instance 3
//        MyBeanClass myBean =  context.getBean(MyBeanClass.class);


//        // create and configure beans
//        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
//
//        // retrieve configured instance
//        Student wangwu = context.getBean("wangwu", Student.class);
//        Student xiaowang = context.getBean("xiaowang",Student.class);
//        System.out.println(wangwu);
//        System.out.println(xiaowang);

//        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
//        Student lisi = context.getBean("lisi", Student.class);
//        System.out.println(lisi);

        // create and configure beans
        Student lisi = context.getBean("lisi", Student.class);
        System.out.println(lisi);

        Teacher w = context.getBean("w", Teacher.class);
        System.out.println(w);

        Course cc = context.getBean("c01", Course.class);
        System.out.println(cc.getCname());
    }
}
